<?php
// Functions for reguser.php

//Checks to see if username exists
function ChkUserName($username) 
{
  		$ChkUsr1 = "SELECT * FROM `user_table` WHERE `username` = '$username'";
  		$ChkUsr2 = mysql_query($ChkUsr1) or die("Could not query user_table");
  		$ChkUsr3 = mysql_fetch_array($ChkUsr2);
		
		if($ChkUsr3 || strlen($username)>25 || strlen($username)<1)
		{
			return 0;
		}
		else
		{
			return 1;
		}
}

// Checks to see if email already exists
function ChkEmail($email) 
{

	$ChkEml1 = "SELECT * FROM `user_table` WHERE `email` = '$email'";
  	$ChkEml2 = mysql_query($ChkEml1) or die("Could not query user_table");
  	$ChkEml3 = mysql_fetch_array($ChkEml2);
	if($ChkEml3 || strlen($email)>50 || strlen($email)<1)
	{
		return 0;
	}
	else
	{
		return 1;
	}
}

// Checks to see if password was typed correctly
function ChkPassword($passworda,$passwordb) 
{
	if((!$passworda || !$passwordb) || ($passworda != $passwordb))
	{
		return 0;
	}
	else if($passworda == $passwordb)
	{
		return 1;
	}
}
?>